package com.sudo.designpattern.singleton;

/**
 * 单例模式-饿汉模式
 * @Author：DayDayUp
 * @Create：2023/4/18 14:31
 */
public class HungrySingleton {
    private static final HungrySingleton instance = new HungrySingleton();

    private HungrySingleton() {
    }

    public static HungrySingleton getInstance() {
        return instance;
    }
}

class TestHungrySingleton{
    public static void main(String[] args) {
        HungrySingleton instance1 = HungrySingleton.getInstance();
        HungrySingleton instance2 = HungrySingleton.getInstance();
        System.out.println(instance1 == instance2);
    }
}
